{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2019-04-01 06:30:00\n",
      "2019-03-31 00:00:00 | 2019-04-01 00:00:00 | 2019-04-02 00:00:00\n",
      "2019-04-01 00:00:00 ≤ 2019-04-01 06:30:00 ＜ 2019-04-02 00:00:00\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "from datetime import date, datetime, timedelta\n",
    "class ClockRound():\n",
    "    def datetime2date(self,dt):\n",
    "        return dt.date()\n",
    "    def date2timestamp(self,d):\n",
    "        return time.mktime(d.timetuple())\n",
    "    def timestamp2datetime(self,ts):\n",
    "        return datetime.fromtimestamp(ts)\n",
    "    def datetime_today_start(self,dt):\n",
    "         return datetime.fromtimestamp(time.mktime(dt.date().timetuple()))\n",
    "    def datetime_tomorrow_start(self,dt):\n",
    "        return datetime.fromtimestamp(time.mktime((dt.date() + timedelta(days=1)).timetuple()))\n",
    "    def datetime_yesterday_start(self,dt):\n",
    "        return datetime.fromtimestamp(time.mktime((dt.date() + timedelta(days=-1)).timetuple()))\n",
    "transfer = ClockRound()\n",
    "x = datetime(2019,4,1,6,30,0)\n",
    "print(x)\n",
    "today_start = transfer.datetime_today_start(x)\n",
    "tomorrow_start = transfer.datetime_tomorrow_start(x)\n",
    "yesterday_start = transfer.datetime_yesterday_start(x)\n",
    "print(\"{} | {} | {}\".format(yesterday_start, today_start, tomorrow_start))\n",
    "print(\"{} ≤ {} ＜ {}\".format(today_start, x, tomorrow_start))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
